package com.example.a001.part24;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent; // 导入Intent类
import android.widget.TextView;

import com.example.a001.R;


public class UserInfoActivity extends AppCompatActivity {

    private TextView tvUsername, tvPassword;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_info); // 确保布局文件名正确

        // 查找控件并绑定
        tvUsername = findViewById(R.id.tv_username); // 确保ID在XML中定义
        tvPassword = findViewById(R.id.tv_password); // 确保ID在XML中定义

        Intent intent = getIntent(); // 获取启动该Activity的Intent
        if (intent != null) { // 防止Intent为空
            String username = intent.getStringExtra("username");
            String password = intent.getStringExtra("password");

            if (username != null && password != null) { // 防止数据为空
                tvUsername.setText("账号: " + username);
                tvPassword.setText("密码: " + password);
            } else {
                tvUsername.setText("账号: 数据为空");
                tvPassword.setText("密码: 数据为空");
            }
        } else {
            tvUsername.setText("账号: Intent为空");
            tvPassword.setText("密码: Intent为空");
        }
    }
}
